package site.luojie.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import site.luojie.entity.COrder;

import java.util.List;

/**
 * C端用户订单
 *
 * @author jie.luo
 * @since 2020/12/15
 */
@Repository
public interface COrderRepository extends JpaRepository<COrder, Long> {

    /**
     * 测试通过 userId 和 id 查询
     *
     * @param userId
     * @param id
     * @return
     */
    COrder findByUserIdAndAndId(Integer userId, Long id);

    /**
     * 测试通过userId 查询
     *
     * @param userId
     * @return
     */
    @Query(value = "select * from c_order c where c.user_id = :userId", nativeQuery = true)
    List<COrder> findByUserId(Integer userId);

}
